package com.amit;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class FilterB  implements Filter{
	
	@Override
	public void init(FilterConfig fc) throws ServletException 
	{
	System.out.println("FilterB-init()");	
		
	}
	
	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		
		System.out.println("FilterB-doFilter");
		String nm=request.getParameter("fname");
		String em=request.getParameter("email");
		
		String ip=request.getRemoteAddr();
		System.out.println(nm);
		System.out.println(em);
		System.out.println(ip);
		System.out.println("FilterB-before calling");
		
		chain.doFilter(request, response);
		System.out.println("FilterB-after calling");
		
		String msg=request.getAttribute("MSG").toString();
		
		System.out.println(msg);
	
	}
	
	@Override
	public void destroy() {
		System.out.println("FilterB-destroy()");
		
	}

}
